package com.itheima.HomeWork_day06;
/*
equals方法
 */
public class ObjectTest02 {
    public static void main(String[] args) {
        Phone p1=new Phone("三星","土豪金");
        Phone p2=new Phone("三星","土豪金");

        System.out.println(p1==p2); //比较地址,结果:false

        //没有重写equals方法前,继承Object
        /*
         public boolean equals(Object obj) {
        return (this == obj);
        }
         */

       // System.out.println(p1.equals(p2)); 重写前返回false

        //重写后,结果为true
        System.out.println(p1.equals(p2));


    }
}
